home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 8: LINUX Games / Linux Cubed Series 8 - LINUX Games.iso / games / x11 / rpg / crossfir.92 / crossfir / crossfire-0.92.5 / crossedit / Cnv / CnvNotify.c < prev    next >
C/C++ Source or Header  |  1996-07-24  |  2KB  |  71 lines

  1. #include <Cnv.h>
  2.  
  3. /**********************************************************************
  4.  * notify
  5.  **********************************************************************/
  6.  
  7. static int CnvNotifyResponce;
  8.  
  9. /*
  10.  * callback: get responce
  11.  */
  12. static void CnvNotifyCb(Widget w,XtPointer client,XtPointer call)
  13. {
  14.   CnvNotifyResponce = (int)client;
  15.   XtDestroyWidget(CnvGetShell(w));
  16. }
  17.  
  18. /*
  19.  * function: show message for user and get responce
  20.  * msg     : message string
  21.  * ...     : user responces, terminated by NULL, eg. "OK","Cancel",NULL
  22.  * return  : selected correspondin responce, eg. OK=1, Cancel=2 or
  23.  *           0 on error
  24.  */
  25. int CnvNotify(String msg,...)
  26. {
  27.   Widget popup,form,use=0,sign;
  28.   va_list al;
  29.   String str;
  30.   int i;
  31.  
  32.   /* creating widgets */
  33.   popup = XtVaCreatePopupShell("notify",transientShellWidgetClass,cnv->shell,
  34.                    NULL);
  35.   form = XtVaCreateManagedWidget("form",formWidgetClass,popup,
  36.                  NULL);
  37.   sign = XtVaCreateManagedWidget("sign",labelWidgetClass,form,
  38.                  XtNbitmap,cnv->xbm.notify,
  39.                  XtNborderWidth,0,
  40.                  XtNheight,34,
  41.                  NULL);
  42.   (void)XtVaCreateManagedWidget("label",labelWidgetClass,form,
  43.                   XtNlabel,msg,
  44.                   XtNborderWidth,0,
  45.                   XtNheight,34,
  46.                   XtNwidth,300,
  47.                   XtNfromHoriz,sign,
  48.                   NULL);
  49.   /* creating given actions */
  50.   va_start(al,msg);
  51.   for(i=1;(str = (String)va_arg(al,String)) != NULL;i++) {
  52.     use = XtVaCreateManagedWidget(str,commandWidgetClass,form,
  53.                   XtNfromHoriz,i == 1 ? NULL : use,
  54.                   XtNfromVert,sign,
  55.                   NULL);
  56.     XtAddCallback(use,XtNcallback,CnvNotifyCb,(XtPointer)i);
  57.   }
  58.   va_end(al);
  59.  
  60.   /* looping */
  61.   CnvCenterWidget(popup);
  62.   XtPopup(popup,XtGrabExclusive);
  63.   CnvNotifyResponce = 0;
  64.   while(!CnvNotifyResponce) {
  65.     XtAppProcessEvent(XtWidgetToApplicationContext(popup),XtIMXEvent);
  66.   }
  67.   return CnvNotifyResponce;
  68. }
  69.  
  70. /*** End of CnvNotify.c ***/
  71.